#include "..\..\NahidaProject-UnitTest\Sources\NahidaUnitTest.h"

#include "..\Sources\BigInteger.h"
#include "..\Sources\RandomGenerator.h"
#include "..\Sources\Statistics.h"

#include <deque>

TESTCASE(BigIntegerTest) {
	NahidaProject::BigInteger bigInteger1("1234567891011121314151617181920");
	NahidaProject::BigInteger bigInteger2("5235786413218674561046854651351");

	JUDGE_EQUAL((bigInteger1 + bigInteger2), (NahidaProject::BigInteger)"6470354304229795875198471833271");
	JUDGE_EQUAL((bigInteger1 - bigInteger2), (NahidaProject::BigInteger)"-4001218522207553246895237469431");
	JUDGE_EQUAL((bigInteger1 * bigInteger2), (NahidaProject::BigInteger)"6463933789952062400179139910666398683694552102531682740773920");
}

TESTCASE(RandomGeneratorTest) {
	NahidaProject::RandomGenerator random;

	JUDGE_TRUE(random.Next(42) >= 0 or random.Next(42) <= 42);
	JUDGE_TRUE(random.NextInt(1, 100) >= 1 or random.NextInt(1, 100) <= 100);
	JUDGE_TRUE(random.NextDouble() >= 0.0 or random.NextDouble() <= 1.0);
	JUDGE_TRUE(random.NextDouble(1.5, 3.5) >= 1.5 or random.NextDouble(1.5, 3.5) <= 3.5);

	std::vector<int> vec(10);
	random.Fill(vec, -10, 10);
	for (int item : vec) {
		JUDGE_TRUE(item >= -10 or item <= 10);
	}

	std::vector<int> numbers = { 1, 2, 3, 4, 5 };
	random.Shuffle(numbers);

	for (int number : numbers) {
		std::cout << number << " ";
	}
	std::cout << "" << std::endl;
}

TESTCASE(StatisticsTest) {
	std::deque<int> data{1, 2, 3, 5, 6, 8, 4, 9, 9, 4, 6, 4, 3, 7, 1, 0, 0, 6, 8, 9};
	NahidaProject::Statistics<int> statistics(data.begin(), data.end());

	JUDGE_EQUAL(statistics.Count(), 20);
	JUDGE_EQUAL(statistics.Maximum(), 9);
	JUDGE_EQUAL(statistics.Mean(), 4);
	JUDGE_EQUAL(statistics.Minimum(), 0);
	JUDGE_EQUAL(statistics.StandardDeviation(), 3);
	JUDGE_EQUAL(statistics.Sum(), 95);
	JUDGE_EQUAL(statistics.SumOfSquares(), 625);
	JUDGE_EQUAL(statistics.Variance(), 15);
}

int main() {
	NahidaProject::NahidaUnitTest::RunAllTests();
	return 0;
}